package channelParam

import (
	"errors"
	"gitee.com/fierce_wolf/go-fox-edge-common/commEnv"
	"gitee.com/fierce_wolf/go-fox-edge-common/commRedisService"
	"gitee.com/fierce_wolf/go-fox-edge-common/edgeEntity"
)

func GetChannelEntity(channelName string) *edgeEntity.ChannelEntity {
	return commRedisService.GetChannelEntity(channelName, commEnv.Service.ModelName)
}

func GetChannelParam(channelName string) (map[string]interface{}, error) {
	// 查找channel实体
	channelEntity := commRedisService.GetChannelEntity(channelName, commEnv.Service.ModelName)
	if channelEntity == nil {
		return nil, errors.New("找不到该通道：" + channelName)
	}

	return channelEntity.ChannelParam, nil
}
